/* eslint valid-jsdoc: "off" */

'use strict';

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1581437665246_2203';

  // add your middleware config here
  config.middleware = ['cors','jwt'];

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
    // mongodb连接池  
    mongoose:{
      url:'mongodb://localhost:27017/ftc',
      options:{
        useNewUrlParser: true ,
        useUnifiedTopology: true,
        useFindAndModify: false,
      },
      plugins:[
        function (err) {
          if (err) {
            console.log('数据库连接成功')
          } else {
            console.log('数据库连接成功,可以搞事情!')
          }
        }
      ]
    },
    io:{
      init:{},
      namespace:{
        "/":{
          connectionMiddleware: [],
          packetMiddleware: [],
        },
        "/admin":{
          connectionMiddleware: ['room'],
          packetMiddleware: [],
        },
      },
    },
    view:{
      defaultViewEngine: 'nunjucks',
      mapping: {
        '.html': 'nunjucks',
      },
    },
    jwt:{
      URL_VERTIFY:[
        '/comment/get',
        '/comment/get',
        '/comment/add',
        '/comment/post',
        '/user/update',
      ],
      TOKEN_ENCODE_STR: 'Ftc_token_encode_str', 
    },
    // 安全配置防范 
    security:{
      csrf: {
        enable: false,
      },
    },
    cluster:{
      listen: {
        port: 7001,
        hostname: '0.0.0.0', // 不建议设置 hostname 为 '0.0.0.0'，它将允许来自外部网络和来源的连接，请在知晓风险的情况下使用
        // path: '/var/run/egg.sock',
      }
    }
  };

  return {
    ...config,
    ...userConfig,
  };
};
